<?php

declare(strict_types=1);

namespace app\admin\controller\settings;


use think\response\Json;
use app\admin\controller\Controller;

class Notice extends Controller
{
    protected $service = null;

    public function initialize()
    {
        parent::initialize();
        $this->service = new \app\admin\service\settings\NoticeService();
    }

    /**
     * 列表
     * @return Json
     * @throws \think\db\exception\DbException
     */
    public function list(): Json
    {
        return success($this->service->list());
    }

    public function detail(): Json
    {
        $id = (int)request()->param('id');
        return success($this->service->detail($id));
    }

    public function create(): Json
    {
        return success('推送成功', $this->service->create(request()->param()));
    }

    public function update( ): Json
    {
        $id = (int)request()->param('id');
        return success('更新成功', $this->service->update($id, request()->param()));
    }

    public function delete(): Json
    {
        $id = (int)request()->param('id');
        return $this->service->delete($id);
    }
}
